package photostock.view.tests;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

import photostock.model.User;
import photostock.view.WebPage;
import photostock.view.Widget;
import photostock.view.WidgetFactory;


public class WebPageTest {

	@Test
	public void getEmptyPage() {
		WebPage page = WidgetFactory.getDefaultPage();
		assertTrue(page.getDocType(), page.getDocType().indexOf("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">") != -1);
		//assertTrue(page.getElement("uploadIFrame") != null);
		assertTrue(page.getHead() != null);
		WidgetFactory.initUser(page, new User("shared"));
		
		System.out.println(((Widget)page.getElement("headerUser")).contentString());
	}
	
//	@Test
	public void addItem() {
		WebPage page = WidgetFactory.getDefaultPage();
//		page.getUser().setContent(WidgetFactory.getWidget(new User("nico")));
		assertTrue(page.getElement("div") != null);
		page = WidgetFactory.getDefaultPage();
	}
	
//	@Test 
	public void addHeader() {
		WebPage page = WidgetFactory.getDefaultPage();
		User u = new User("nico");
		u.login("atreides");
	//	page.getUser().setContent(WidgetFactory.getWidget(u));
		WidgetFactory.addScript(page, "test");	
		assertTrue(page.getElement("script") != null);
		WidgetFactory.addStyle(page, "newStyle");	
		WidgetFactory.addScript(page, "user");	
		assertTrue(page.getElement("style") != null);
		System.out.println(page.toString());
		
	}
}
